#pragma once

#include <grpcpp/support/status.h>

#include <unordered_map>
#include <mutex>

#include "monitor_info.grpc.pb.h"
#include "monitor_info.pb.h"

namespace monitor
{
    class GrpcManagerServiceImpl : public monitor::proto::GrpcManager::Service
    {
    public:
        GrpcManagerServiceImpl();

        virtual ~GrpcManagerServiceImpl();

        ::grpc::Status SetMonitorInfo(::grpc::ServerContext *context,
                                      const ::monitor::proto::MonitorInfo *request,
                                      ::google::protobuf::Empty *response);
        ::grpc::Status GetMonitorInfo(::grpc::ServerContext *context,
                                      const ::monitor::proto::GetRequest *request,
                                      ::monitor::proto::MonitorInfo *response);

    private:
        std::unordered_map<std::string, monitor::proto::MonitorInfo> monitor_map_;
        mutable std::mutex map_mutex_;
    };

} // namespace monitor
